package com.autumn.xa.a.tuling.jvm;

import org.openjdk.jol.info.ClassLayout;

/**
 * ClassName: JOLDemo
 *
 * @Description:
 * @Author: wangqiuyang
 * @Date: 2022/6/24 11:16 PM
 * History:
 * <author>          <time>          <version>          <desc>
 * wangqiuyang    2022/6/24 11:16 PM   @Version 1.0        描述
 */
public class JOLDemo {
    public static void main(String[] args) {
        ClassLayout layout = ClassLayout.parseInstance(new Object());
        System.out.println(layout.toPrintable());

        System.out.println();
        ClassLayout layout1 = ClassLayout.parseInstance(new int[]{});
        System.out.println(layout1.toPrintable());

        System.out.println();
        ClassLayout layout2 = ClassLayout.parseInstance(new A());
        System.out.println(layout2.toPrintable());
    }
    public static class A {
                       //8B mark word
                       //4B Klass Pointer   如果关闭压缩-XX:-UseCompressedClassPointers或-XX:-UseCompressedOops，则占用8B
        int id;        //4B
        String name;   //4B  如果关闭压缩-XX:-UseCompressedOops，则占用8B
        byte b;        //1B
        Object o;      //4B  如果关闭压缩-XX:-UseCompressedOops，则占用8B
    }
}
